#include "teacherterminal.h"
#include <QApplication>

#include "networkmanager.h"
#include "mainface.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    NetworkManager networkManager;
    if(!networkManager.connectToServer("192.168.5.21",8080))
    {
        QMessageBox::critical(nullptr,"Error","Failed to connect to server!");
        return -1;
    }

    Mainface mainface(nullptr,&networkManager);
    TeacherTerminal teaTer(nullptr,&networkManager);

    // 连接mainface的ReginBtnClicked信号到TeacherTerminal的show槽
//    QObject::connect(&mainface,&Mainface::ReginBtnClicked,&teaTer,&TeacherTerminal::show);

    QObject::connect(&mainface,&Mainface::ReginSuccess,[&](){
        mainface.hide();    // 隐藏Mainface界面
        teaTer.show();      // 显示TeacherTermianl界面
    });

#if 0
    // 先显示mainface
    mainface.show();
#else
    teaTer.show();
#endif

    return a.exec();
}
